home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / tools / unique.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  887 b   |  40 lines

  1. /*------------------------------------------------------------------------
  2.  * $Id: unique.c,v 1.1 1992/10/07 15:55:18 carlson Exp $
  3.  *
  4.  * This program takes all the arguments from the command line and removes
  5.  * duplicates.  It writes to stdout the resulting list.
  6.  *
  7.  * Revision History:
  8.  *    $Log: unique.c,v $
  9.  * Revision 1.1  1992/10/07  15:55:18  carlson
  10.  * Initial revision
  11.  *
  12.  *------------------------------------------------------------------------*/
  13.  
  14. #include <stdio.h>
  15. #include <errno.h>
  16. #include <string.h>
  17.  
  18. main (int argc, char *argv[])
  19. {
  20.     char **arg0, **argN;
  21.  
  22.     for (arg0 = argv + 1; *arg0; arg0++) {
  23.     if (**arg0 == 0xFF)
  24.         continue;
  25.     for (argN = arg0 + 1; *argN; argN++) {
  26.         if (**argN == 0xFF)
  27.         continue;
  28.         if (strcmp (*arg0, *argN) == 0) {
  29.         **argN = 0xFF;
  30.         continue;
  31.         }
  32.     }
  33.  
  34.     if (*argN == NULL)
  35.         printf ("%s ", *arg0);
  36.     }
  37.  
  38.     printf ("\n");
  39. }
  40.